package com.mengniu.commerce.admin.api.factory;

import com.mengniu.commerce.admin.api.domain.bo.RemoteSocialBo;
import com.mengniu.commerce.admin.api.domain.vo.RemoteSocialVo;
import com.mengniu.commerce.admin.api.RemoteSocialService;
import com.mengniu.commerce.common.core.domain.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author: dgyu-398305246@qq.com
 * @createTime: 2023年12月03 21:25:52
 * @description: 社交服务服务降级处理
 */
@Component
public class RemoteSocialFallbackFactory implements FallbackFactory<RemoteSocialService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteSocialFallbackFactory.class);

    @Override
    public RemoteSocialService create(Throwable throwable)
    {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteSocialService()
        {


            @Override
            public R<List<RemoteSocialVo>> selectByAuthId(String authId) {
                return R.fail("根据 authId 查询用户信息失败:" + throwable.getMessage());
            }

            @Override
            public R<Void> insertByBo(RemoteSocialBo bo) {
                return R.fail("保存社会化关系失败:" + throwable.getMessage());
            }

            @Override
            public R<Void> updateByBo(RemoteSocialBo bo) {
                return R.fail("更新社会化关系失败:" + throwable.getMessage());
            }

            @Override
            public R<Boolean> unlock(String socialId) {
                return R.fail("删除社会化关系失败:" + throwable.getMessage());
            }
        };
    }
}
